package a.i;

import a.c.q;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.font.FontRenderContext;
import java.awt.font.LineBreakMeasurer;
import java.awt.geom.AffineTransform;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.AttributedString;
import java.text.BreakIterator;
import java.util.ArrayList;
import java.util.Iterator;

public class xb
  extends JPanel
{
  private Throwable a;
  private String b;
  private String c;
  private String d;
  private Action e;
  private Action f;
  private JButton g;
  private boolean h;
  private JComponent i;
  private JComponent j;
  private transient ArrayList k;
  private Action[] l;
  private int m = 400;
  static Class n;
  public static boolean o;
  
  public xb(Exception paramException)
  {
    this("An Exception has Occured:", false, paramException);
  }
  
  public xb(Throwable paramThrowable)
  {
    this("An Error has Occured:", false, paramThrowable);
  }
  
  protected xb(String paramString, boolean paramBoolean, Exception paramException)
  {
    this(paramString, paramBoolean, paramException);
  }
  
  protected xb(String paramString, boolean paramBoolean, Throwable paramThrowable)
  {
    super(new BorderLayout());
    this.a = paramThrowable;
    this.d = paramString;
    this.b = this.a.getLocalizedMessage();
    if (!bool) {
      if (this.b == null) {
        this.b = this.a.getMessage();
      }
    }
    if ((bool) || (this.b == null)) {
      this.b = this.a.toString();
    }
    StringWriter localStringWriter = new StringWriter();
    PrintWriter localPrintWriter = new PrintWriter(localStringWriter);
    try
    {
      this.a.printStackTrace(localPrintWriter);
      localStringWriter.close();
      localPrintWriter.close();
    }
    catch (IOException localIOException) {}
    this.c = localStringWriter.toString();
    a(paramBoolean);
  }
  
  public xb(String paramString1, String paramString2, String paramString3, boolean paramBoolean)
  {
    super(new BorderLayout());
    this.d = paramString1;
    if (!p.b) {}
    this.b = (paramString2 != null ? paramString2 : "");
    this.c = paramString3;
    a(paramBoolean);
  }
  
  private void a(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      this.f = b();
      this.g = c(this.f);
    }
    this.e = a();
    String str = h();
    if (((p.b) || (str != null)) && (str.length() > 0)) {
      add(a(str), "North");
    }
    JPanel localJPanel = new JPanel(new BorderLayout());
    this.i = b(this.b);
    this.i.setName("SHORT_TEXT");
    this.j = a(this.b, this.c);
    localJPanel.add(this.i, "Center");
    add(localJPanel, "Center");
    localJPanel.add(c(), "South");
  }
  
  protected Action a()
  {
    e_ locale_ = new e_();
    a(locale_);
    return locale_;
  }
  
  protected Action b()
  {
    d_ locald_ = new d_();
    b(locald_);
    return locald_;
  }
  
  protected void a(Action paramAction)
  {
    paramAction.putValue("Name", "Details >>");
    paramAction.putValue("ShortDescription", "Toggles Visibility of Details");
    paramAction.putValue("AcceleratorKey", KeyStroke.getKeyStroke("alt D"));
  }
  
  protected void b(Action paramAction)
  {
    paramAction.putValue("Name", "Ok");
    paramAction.putValue("ShortDescription", "Close Dialog");
    paramAction.putValue("AcceleratorKey", KeyStroke.getKeyStroke("ENTER"));
  }
  
  protected JComponent a(String paramString)
  {
    JLabel localJLabel = new JLabel(paramString);
    localJLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0));
    return localJLabel;
  }
  
  protected JComponent b(String paramString)
  {
    boolean bool2 = p.b;
    boolean bool1 = p.a;
    AttributedString localAttributedString = new AttributedString(paramString);
    BreakIterator localBreakIterator = BreakIterator.getWordInstance();
    FontRenderContext localFontRenderContext = new FontRenderContext(new AffineTransform(), false, false);
    LineBreakMeasurer localLineBreakMeasurer = new LineBreakMeasurer(localAttributedString.getIterator(), localBreakIterator, localFontRenderContext);
    ArrayList localArrayList = new ArrayList();
    int i1 = 0;
    int i2 = localLineBreakMeasurer.nextOffset(this.m);
    localArrayList.add(paramString.substring(i1, i2));
    i1 = i2;
    i2 = localLineBreakMeasurer.nextOffset(this.m, paramString.length(), true);
    localLineBreakMeasurer.setPosition(i2);
    do
    {
      if (i1 < paramString.length()) {
        break;
      }
    } while (bool1);
    if (localArrayList.size() > 1)
    {
      JPanel localJPanel = new JPanel(null);
      localJPanel.setLayout(new BoxLayout(localJPanel, 1));
      localJPanel.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 0));
      Iterator localIterator = localArrayList.iterator();
      while (localIterator.hasNext())
      {
        String str = (String)localIterator.next();
        JLabel localJLabel = new JLabel(str);
        if ((!bool2) && (bool1)) {
          break label275;
        }
        localJPanel.add(localJLabel);
        if (bool1)
        {
          if (!bool2) {}
          q.n = !q.n;
        }
      }
      label275:
      return localJPanel;
    }
    if (q.o) {
      p.b = !bool2;
    }
    return new JLabel(paramString);
  }
  
  protected JComponent a(String paramString1, String paramString2)
  {
    if (((!p.b) && (paramString2 == null)) || (paramString2.length() < 1)) {
      return null;
    }
    JTextArea localJTextArea = new JTextArea();
    localJTextArea.setEditable(false);
    localJTextArea.setWrapStyleWord(true);
    localJTextArea.setLineWrap(false);
    localJTextArea.setText(paramString2);
    JScrollPane localJScrollPane = new JScrollPane(localJTextArea, 20, 30);
    Dimension localDimension = localJTextArea.getPreferredScrollableViewportSize();
    localDimension.height = Math.min(localDimension.height + 32, 250);
    localDimension.width = Math.min(localDimension.width + 32, this.m);
    localJScrollPane.setMaximumSize(localDimension);
    localJScrollPane.setPreferredSize(localDimension);
    return localJScrollPane;
  }
  
  protected JComponent c()
  {
    boolean bool = p.b;
    JPanel localJPanel = new JPanel();
    BoxLayout localBoxLayout = new BoxLayout(localJPanel, 0);
    localJPanel.setLayout(localBoxLayout);
    Dimension localDimension = new Dimension(11, 11);
    if (!bool)
    {
      if (this.g != null)
      {
        localJPanel.add(this.g);
        localJPanel.add(Box.createRigidArea(localDimension));
      }
      localJPanel.add(Box.createHorizontalGlue());
      localJPanel.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 0));
      if (bool) {}
    }
    else if (this.j != null)
    {
      JButton localJButton = d(this.e);
      localJPanel.add(localJButton);
    }
    return localJPanel;
  }
  
  protected JButton c(Action paramAction)
  {
    return new JButton(paramAction);
  }
  
  protected JButton d(Action paramAction)
  {
    return c(paramAction);
  }
  
  public Exception d()
  {
    if ((p.b) || ((this.a instanceof Exception))) {
      return (Exception)this.a;
    }
    return null;
  }
  
  public Throwable e()
  {
    return this.a;
  }
  
  public String f()
  {
    return this.b;
  }
  
  public String g()
  {
    return this.c;
  }
  
  public String h()
  {
    return this.d;
  }
  
  public boolean i()
  {
    return this.h;
  }
  
  public void b(boolean paramBoolean)
  {
    boolean bool3 = p.b;
    boolean bool2 = p.a;
    if (!bool3) {
      if (paramBoolean == this.h) {
        return;
      }
    }
    boolean bool1 = this.h;
    this.h = paramBoolean;
    firePropertyChange("detailsShowing", bool1, paramBoolean);
    a(new ActionEvent(this, 1001, "TOGGLE_DETAILS"));
    if (!bool3) {
      if (paramBoolean)
      {
        add(this.j, "South");
        this.e.putValue("Name", "Details <<");
        if (!bool3) {
          if (!bool2) {
            break label122;
          }
        }
      }
      else
      {
        remove(this.j);
      }
    }
    this.e.putValue("Name", "Details >>");
    label122:
    if (!bool3) {}
    Container localContainer = SwingUtilities.getAncestorOfClass(n == null ? (xb.n = c("javax.swing.JInternalFrame")) : n, this);
    if (!bool3)
    {
      revalidate();
      if (localContainer != null)
      {
        ((JInternalFrame)localContainer).pack();
        if (!bool2) {
          return;
        }
      }
    }
    Window localWindow = SwingUtilities.getWindowAncestor(this);
    if ((bool3) || (localWindow != null)) {
      localWindow.pack();
    }
  }
  
  public void a(Component paramComponent, int paramInt, String paramString)
  {
    JOptionPane localJOptionPane = new JOptionPane(this, paramInt);
    if (this.f != null) {
      localJOptionPane.setOptions(new Object[0]);
    }
    JDialog localJDialog = localJOptionPane.createDialog(paramComponent, paramString);
    if (!p.b)
    {
      if (this.g != null)
      {
        localJDialog.getRootPane().setDefaultButton(this.g);
        this.g.addActionListener(new ActionListener()
        {
          private final JDialog val$d;
          
          public void actionPerformed(ActionEvent paramAnonymousActionEvent)
          {
            this.val$d.setVisible(false);
            this.val$d.dispose();
          }
        });
      }
      localJDialog.setVisible(true);
    }
  }
  
  public static void a(Component paramComponent, String paramString, Exception paramException)
  {
    a(paramComponent, paramString, 0, paramException);
  }
  
  public static void a(Component paramComponent, String paramString, int paramInt, Exception paramException)
  {
    a(paramComponent, paramString, paramInt, paramException);
  }
  
  public static void a(Component paramComponent, String paramString, Throwable paramThrowable)
  {
    a(paramComponent, paramString, 0, paramThrowable);
  }
  
  public static void a(Component paramComponent, String paramString, int paramInt, Throwable paramThrowable)
  {
    if (!p.b)
    {
      if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable()
        {
          private final Throwable val$t;
          private final Component val$parent;
          private final int val$messagetype;
          private final String val$dialogTitle;
          
          public void run()
          {
            xb localxb = new xb("An Exception has Occured:", true, this.val$t);
            localxb.a(this.val$parent, this.val$messagetype, this.val$dialogTitle);
          }
        });
      }
    }
    else if (!p.a) {
      return;
    }
    xb localxb = new xb("An Exception has Occured:", true, paramThrowable);
    localxb.a(paramComponent, paramInt, paramString);
  }
  
  public static void a(Component paramComponent, String paramString1, String paramString2, String paramString3)
  {
    a(paramComponent, paramString1, 0, paramString2, paramString3);
  }
  
  public static void a(Component paramComponent, String paramString1, int paramInt, String paramString2, String paramString3)
  {
    int i1 = paramString3.indexOf('\n');
    String str2 = null;
    String str1;
    if (i1 > 0)
    {
      str1 = paramString3.substring(0, i1);
      if ((p.b) || (paramString3.length() > i1 + 1)) {
        str2 = paramString3.substring(i1 + 1);
      }
    }
    else
    {
      str1 = paramString3;
    }
    Object localObject;
    if (!SwingUtilities.isEventDispatchThread())
    {
      localObject = str2;
      SwingUtilities.invokeLater(new Runnable()
      {
        private final String val$label;
        private final String val$shortText;
        private final String val$longText1;
        private final Component val$parent;
        private final int val$messagetype;
        private final String val$dialogTitle;
        
        public void run()
        {
          xb localxb = new xb(this.val$label, this.val$shortText, this.val$longText1, true);
          localxb.a(this.val$parent, this.val$messagetype, this.val$dialogTitle);
        }
      });
      if (!p.a) {}
    }
    else
    {
      localObject = new xb(paramString2, str1, str2, true);
      ((xb)localObject).a(paramComponent, paramInt, paramString1);
    }
  }
  
  public synchronized void a(ActionListener paramActionListener)
  {
    if (!p.b) {
      if (this.k == null) {
        this.k = new ArrayList();
      }
    }
    this.k.add(paramActionListener);
  }
  
  public synchronized void b(ActionListener paramActionListener)
  {
    if ((p.b) || (this.k != null)) {
      this.k.remove(paramActionListener);
    }
  }
  
  private void a(ActionEvent paramActionEvent)
  {
    boolean bool2 = p.b;
    boolean bool1 = p.a;
    ArrayList localArrayList;
    synchronized (this)
    {
      if (!bool2) {
        if (this.k == null) {
          return;
        }
      }
      localArrayList = (ArrayList)this.k.clone();
    }
    do
    {
      for (int i1 = 0; !bool1; i1++)
      {
        if (i1 >= localArrayList.size()) {
          break;
        }
        ((ActionListener)localArrayList.get(i1)).actionPerformed(paramActionEvent);
      }
    } while (bool2);
  }
  
  public int j()
  {
    return this.m;
  }
  
  public void a(int paramInt)
  {
    this.m = paramInt;
  }
  
  static Class c(String paramString)
  {
    try
    {
      return Class.forName(paramString);
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }
  
  private final class d_
    extends AbstractAction
  {
    d_()
    {
      super();
      putValue("ActionCommandKey", "OK");
    }
    
    public void actionPerformed(ActionEvent paramActionEvent)
    {
      xb.this.a(paramActionEvent);
    }
  }
  
  private final class e_
    extends AbstractAction
  {
    e_()
    {
      super();
      putValue("ActionCommandKey", "TOGGLE_DETAILS");
    }
    
    public void actionPerformed(ActionEvent paramActionEvent)
    {
      if (!p.b) {}
      xb.this.b(!xb.this.i());
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.i.xb

 * JD-Core Version:    0.7.0.1

 */